package com.foreknow.elm.controller;




import com.foreknow.elm.po.User;
import com.foreknow.elm.service.Impl.UserServiceImpl;
import com.foreknow.elm.service.UserService;

import javax.servlet.http.HttpServletRequest;

public class UserController {
    public Object getUserByIdByPass(HttpServletRequest request){
        //获取前台请求参数 /UserController/getUserByIdByPass?userId=3333333333&password=123456
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        UserService userService = new UserServiceImpl();
        User user = userService.getUserByIdByPass(userId,password);
        return user;
    }
    public Object getUserById(HttpServletRequest request){
        //获取前台请求参数 /UserController/getUserById?userId=3333333333
        String userId = request.getParameter("userId");
        UserService userService = new UserServiceImpl();
        int result= userService.getUserById(userId);
        return result;
    }
    public Object saveUser(HttpServletRequest request){
        //获取前台请求参数 /UserController/saveUser?userId=3333333333&password=4234&userName=4534534&userSex=1
        String userId = request.getParameter("userId");
        String password = request.getParameter("password");
        String userName = request.getParameter("userName");
        Integer userSex = Integer.parseInt(request.getParameter("userSex")) ;
        UserService userService = new UserServiceImpl();
        int result= userService.saveUser(userId,password,userName,userSex);
        return result;
    }
}